//
//  YFHomeOneReusableView.m
//  QuanJieShopProject
//
//  Created by 杨帆 on 2018/3/28.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "YFHomeOneReusableView.h"

@interface YFHomeOneReusableView ()
@property (nonatomic, strong) UILabel *titleLabel;
@end

@implementation YFHomeOneReusableView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        KMyLog(@"size = %f, h = %f", frame.size.width, frame.size.height);
        [self makeView:frame];
    }
    return self;
}

- (void)makeView:(CGRect)frame {
    
//    self.backgroundColor = [UIColor blueColor];
    
    CGFloat padding = 10;
    // 中文名字
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.font = [UIFont boldSystemFontOfSize:12];
    titleLabel.textColor = YFColor_Text;
    titleLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:titleLabel];
    self.titleLabel = titleLabel;
    
    // 左边横线
    UIView *leftLine = [[UIView alloc] init];
    leftLine.backgroundColor = [UIColor colorWithHexString:@"dddddd"];
    [self addSubview:leftLine];
    
    // 左边横线
    UIView *rightLine = [[UIView alloc] init];
    rightLine.backgroundColor = [UIColor colorWithHexString:@"dddddd"];
    [self addSubview:rightLine];

    // 下划线
    UIView *bottomLine = [[UIView alloc] init];
    bottomLine.backgroundColor = [UIColor colorWithHexString:@"#dddddd"];
    [self addSubview:bottomLine];
    
    // 顶部横线
    UIView *topLine = [[UIView alloc] init];
    topLine.backgroundColor = [UIColor colorWithHexString:@"#dddddd"];
    [self addSubview:topLine];
    
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@90);
        make.height.top.equalTo(self);
        make.centerX.equalTo(self);
    }];
    
    [leftLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(30));
        make.height.equalTo(@(0.5));
        make.centerY.equalTo(self.titleLabel.mas_centerY);
        make.right.equalTo(self.titleLabel.mas_left);
    }];
    
    [rightLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(25));
        make.height.equalTo(@(0.5));
        make.centerY.equalTo(self.titleLabel.mas_centerY);
        make.left.equalTo(self.titleLabel.mas_right);
    }];
    
//    [bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.height.equalTo(@(0.5));
//        make.left.right.bottom.equalTo(self);
//    }];
    
    [topLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@(0.5));
        make.left.right.top.equalTo(self);
    }];
}

//-(void)updateHeaderWithSection:(NSInteger)section{
//    switch (section) {
//        case 0:
//        {
////            self.headerTitleLabel.text = @"今日爆款";
//            self.chineseTitle = @"限时秒杀2";
//            self.englishTitle = @"Time limit Sale";
////            [self reset];
//        }
//            break;
//        case 1: // 只有这一个
//        {
////            self.headerTitleLabel.text = @"人气推荐";
//            self.chineseTitle = @"猜你喜欢";
//            self.englishTitle = @"Guess what you";
////            [self reset];
//        }
//            break;
//        case 3:
//        {
////            self.headerTitleLabel.text = @"猜你喜欢";
////            self.chineseTitle = @"限时秒杀";
////            self.englishTitle = @"Time limit Sale";;
////            [self reset];
//        }
//            break;
//
//        default:
//            break;
//    }
//}

- (void)setTitle:(NSString *)title {
    _title = title;
    self.titleLabel.text = title;
}


//- (void)reset {
//    self.chineseLabel.text = self.chineseTitle;
//    self.englishLabel.text = self.englishTitle;
//}
@end
